/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package main;
import java.io.*;
/**
 *
 * @author Mantas, Ramūnas, Vilius
 */

public class Processor {
    private static String SF;
    private static Integer step = 0;
    private static String IP;
    private static String SP;
    private static Integer MODE;
    private static Integer TIMER;
    private static Integer PI;
    /**
     * SI reiksmes
     *  0 - nera pertraukimo
     *  1 - halt
     *  2 - input
     */
  
    private static Integer SI;
    private static Integer TI;
    private static Integer PTR;
    private static Integer SPTR;
    
    private static String InOut = "";
    //Darbas su failu
    public static RandomAccessFile workFile;
    public static String fileName;
    
   
    public static void setIP(String setIP) {
        IP = setIP;
    }
    
    public static void setSP(String setSP) {
        SP = setSP;
    }
    
    public static void setStep(Integer setStep) {
        step = setStep;
    }
    
    public static void setMODE(Integer setMODE) {
        MODE = setMODE;
    }

    public static void setPI(Integer setPI) {
        PI = setPI;
    }

    public static void setPTR(Integer setPTR) {
        PTR = setPTR;
    }
    
    public static void setSPTR(Integer setSPTR) {
        SPTR = setSPTR;
    }

    public static void setSF(String setSF) {
        SF = setSF;
    }

    public static void setSI(Integer setSI) {
        SI = setSI;
    }

    public static void setTI(Integer setTI) {
        TI = setTI;
    }

    public static void setTIMER(Integer setTIMER) {
        TIMER = setTIMER;
        Processor.setTI(0);
        if( TIMER > 9) {
            Processor.setTI(1);
            TIMER = 0;
        }
    }
    
    public static String setInOut(String setInOut) {
        InOut = InOut+setInOut;
        return InOut;
    }
    
    public static String clearInOut() {
        InOut = "";
        return InOut;
    }
    
    public static String getIP() {
        return IP;
    }
    
    public static String getSP() {
        return SP;
    }
    
    public static Integer getMODE() {
        return MODE;
    }
    
    public static String getInOut() {
        return InOut;
    }
    
    public static Integer getPI() {
        return PI;
    }

    public static Integer getStep() {
        return step;
    }
    
    public static Integer getPTR() {
        return PTR;
    }
    
    public static Integer getSPTR() {
        return SPTR;
    }

    public static String getSF() {
        return SF;
    }

    public static Integer getSI() {
        return SI;
    }

    public static Integer getTI() {
        return TI;
    }

    public static Integer getTIMER() {
        return TIMER;
    }
    public static Integer hexToDec(String s) {
        switch(s.charAt(0)){
            default: return Integer.parseInt(s);
            case 'A': return 10;
            case 'B': return 11;
            case 'C': return 12;
            case 'D': return 13;
            case 'E': return 14;
            case 'F': return 15;
            
        }
    }
    public static String replaceCharAt(String s, int pos, char c) {
        return s.substring(0,pos) + c + s.substring(pos+1);
    }
    public static String convertXtoXX(Integer number){
        if(number<10){
            return '0'+number.toString();
        }
        else{
            return number.toString();
        }
    }
}
